//
//  NSDictionary+KLJson.m
//  ipaimai
//
//  Created by Tommy on 15/6/1.
//  Copyright (c) 2015年 taobao. All rights reserved.
//

#import "NSDictionary+KLJson.h"

@implementation NSDictionary (KLJson)

+ (NSDictionary *)kl_dictionaryWithJsonString:(NSString *)jsonString{
    NSError *jsonError = nil;
    NSData* jsonData =  nil;
    id jsonObject = nil;
    if(!jsonString)
        return nil;
    @try {
        jsonData =  [jsonString dataUsingEncoding:NSUTF8StringEncoding];
        jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData
                                                     options:NSJSONReadingAllowFragments
                                                       error:&jsonError];
    }
    @catch (NSException *exception) {
        return nil;
    }
    

    if (jsonObject != nil && jsonError == nil){
        return jsonObject;
    }else{
        // 解析错误
        return nil;
    }

}



@end
